<template>
  <div class="app-container">
    <el-card class="operate-container" shadow="never">
      <span>参数设置</span>
    </el-card>
    <div class="total-layout">
      <el-row :gutter="20">
        <el-col :span="6">
          <div class="total-frame">
            <div class="total-title">
              <span>名称设置</span>
              <span class="total-title">
                <el-button size="mini" type="text" @click="handleUpdate(1, 1)">编辑</el-button>
              </span>
            </div>
            <div class="total-value">200</div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="total-frame">
            <div class="total-title">
              <span>招商提示设置</span>
              <span class="total-title">
                <el-button size="mini" type="text" @click="handleUpdate(1, 1)">编辑</el-button>
              </span>
            </div>
            <div class="total-value">5000.00</div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="total-frame">
            <div class="total-title">
              <span>客服电话设置</span>
              <span class="total-title">
                <el-button size="mini" type="text" @click="handleUpdate(1, 1)">编辑</el-button>
              </span>
            </div>
            <div class="total-value">￥5000.00</div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="total-frame">
            <div class="total-title">
              <span>会员佣金设置</span>
              <span class="total-title">
                <el-button size="mini" type="text" @click="handleUpdate(1, 1)">编辑</el-button>
              </span>
            </div>
            <div class="total-value">￥5000.00</div>
          </div>
        </el-col>
      </el-row>
    </div>
    <div class="total-layout">
      <el-row :gutter="10">
        <el-col :span="6">
          <div class="total-frame">
            <div class="total-title">
              <span>积分兑换比例设置</span>
              <span class="total-title">
                <el-button size="mini" type="text" @click="handleUpdate(1, 1)">编辑</el-button>
              </span>
            </div>
            <div class="total-value">200</div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="total-frame">
            <div class="total-title">
              <span>会员注册协议设置</span>
              <span class="total-title">
                <el-button size="mini" type="text" @click="handleUpdate(1, 1)">编辑</el-button>
              </span>
            </div>
            <div class="total-value">5000.00</div>
          </div>
        </el-col>
      </el-row>
    </div>
    <el-dialog title="修改" :visible.sync="dialogVisible" width="30%">
      <el-form :model="returnReason" ref="reasonForm" label-width="150px">
        <el-form-item label="原因类型：">
          <el-input v-model="returnReason" class="input-width"></el-input>
        </el-form-item>
        <el-form-item label="排序：">
          <el-input v-model="returnReason" class="input-width"></el-input>
        </el-form-item>
        <el-form-item label="是否启用：">
          <el-switch v-model="returnReason" :active-value="1" :inactive-value="0"></el-switch>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="handleConfirm">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import {
  fetchList,
  updateDeleteStatus,
  updateNewStatus,
  updateRecommendStatus,
  updatePublishStatus
} from "@/api/product";

import { fetchList as fetchProductAttrList } from "@/api/productAttr";
import { fetchListWithChildren } from "@/api/productCate";

const defaultListQuery = {
  keyword: null,
  pageNum: 1,
  pageSize: 5,
  publishStatus: null,
  verifyStatus: null,
  productSn: null,
  productCategoryId: null,
  brandId: null
};
export default {
  name: "productList",
  data() {
    return {
      operateType: null,
      listQuery: Object.assign({}, defaultListQuery),
      list: null,
      total: null,
      listLoading: true,
      selectProductCateValue: null,
      multipleSelection: [],
      productCateOptions: [],
      brandOptions: [],
      dialogVisible: false,
      returnReason: null
    };
  },
  created() {
    this.getList();
  },
  watch: {
    selectProductCateValue: function(newValue) {
      if (newValue != null && newValue.length == 2) {
        this.listQuery.productCategoryId = newValue[1];
      } else {
        this.listQuery.productCategoryId = null;
      }
    }
  },
  filters: {
    verifyStatusFilter(value) {
      if (value === 1) {
        return "审核通过";
      } else {
        return "未审核";
      }
    }
  },
  methods: {
    getProductSkuSp(row, index) {
      if (index === 0) {
        return row.sp1;
      } else if (index === 1) {
        return row.sp2;
      } else {
        return row.sp3;
      }
    },
    handleUpdate(index, row) {
      this.dialogVisible = true;
      // this.operateReasonId=row.id;
      // getReasonDetail(row.id).then(response=>{
      //   this.returnReason=response.data;
      //  });
    },
    getList() {
      this.listLoading = true;
      fetchList(this.listQuery).then(response => {
        this.listLoading = false;
        this.list = response.data.list;
        this.total = response.data.total;
      });
    },
    handleConfirm() {
      if (this.operateReasonId == null) {
        //添加操作
        addReason(this.returnReason).then(response => {
          this.dialogVisible = false;
          this.operateReasonId = null;
          this.$message({
            message: "添加成功！",
            type: "success",
            duration: 1000
          });
          this.getList();
        });
      } else {
        //编辑操作
        updateReason(this.operateReasonId, this.returnReason).then(response => {
          this.dialogVisible = false;
          this.operateReasonId = null;
          this.$message({
            message: "修改成功！",
            type: "success",
            duration: 1000
          });
          this.getList();
        });
      }
    },
    updateDeleteStatus(deleteStatus, ids) {
      let params = new URLSearchParams();
      params.append("ids", ids);
      params.append("deleteStatus", deleteStatus);
      updateDeleteStatus(params).then(response => {
        this.$message({
          message: "删除成功",
          type: "success",
          duration: 1000
        });
      });
      this.getList();
    }
  }
};
</script>
<style rel="stylesheet/scss"  scoped>
.app-container {
  background: #fff;
  min-height: 500px;
}
.total-layout {
  margin-top: 40px;
}
.total-frame {
  border: 1px solid #dcdfe6;
  padding: 20px;
  height: 180px;
}
.total-icon {
  color: #409eff;
  width: 60px;
  height: 60px;
}

.total-title {
  position: relative;
  font-size: 18px;
  color: #909399;
  margin-bottom: 10px;
  /* left: 70px;
  top: 7px; */
}
.el-button--text {
  font-size: 18px !important;
  float: right;
}
.total-value {
  position: relative;
  font-size: 18px;
  color: #606266;
  /* left: 70px;
  top: 19px; */
}
</style>


